﻿using HelloWPF.Command.Command;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Documents;
using model = HelloWPF.Command.Models;

namespace HelloWPF.Command.ViewModel
{
    public class MainViewModel
    {
        #region 命令属性
        public CommandBase BtnHelloCommand { get; set; }

        public CommandBase BtnWorldCommand { get; set; }
        #endregion

        public model.MainModel MainModel { get; set; } = new model.MainModel();

        /// <summary>
        /// ctor
        /// </summary>
        public MainViewModel()
        {
            Console.WriteLine($"Main ThreadId:{Thread.CurrentThread.ManagedThreadId.ToString("00")}");

            BtnHelloCommand = new CommandBase()
            {
                DoExecute = new Action<object>(SayHello),
                DoCanExecute = new Func<object, bool>(CanHello)
            };
            BtnHelloCommand.CanExecuteChanged += (se, ev) =>
            {
                string statusText = "不停的状态检查";
            };
            BtnWorldCommand = new CommandBase()
            {
                DoExecute = new Action<object>(SayWorld),
                DoCanExecute = new Func<object, bool>(CanWorld)
            };
        }

        public void SayHello(object obj)
        {

        }

        public bool CanHello(object obj)
        {
            Console.WriteLine($"CanHello ThreadId:{Thread.CurrentThread.ManagedThreadId.ToString("00")}");

            return true;
        }

        public void SayWorld(object obj)
        {

        }

        public bool CanWorld(object obj)
        {
            return true;
        }

    }
}
